<template>
  <div style="position:relative">
    <img v-for="(item,index) in xqimg" :key="index" :src="item" />
    <img src="../../assets/img/fanhui.png" class="icon" alt @click="gogood" />
  </div>
</template>

<script>
import goodApi from "@/api/goodApi";
import { Dialog } from 'vant';
export default {
  data() {
    return {
      xqimg: []
    };
  },

  components: {
       [Dialog.Component.name]: Dialog.Component,
  },

  methods: {
    gogood() {
      this.$router.push("/details?" + this.$route.fullPath.split("?")[1]);
    },
    async getgood() {
       
      try {
        if (this.$route.fullPath.split("?")[1]) {
          let id = this.$route.fullPath.split("?")[1];
          console.log(id, 999);
          let p = await goodApi.good(id);
          console.log(p.data.flag);
          if (p.data.flag) {
            this.xqimg = p.data.data[0].xqimg;
            this.xqimg = this.xqimg.replace("[", "");
            this.xqimg = this.xqimg.replace("]", "");
            this.xqimg = this.xqimg.split(",");
            console.log(this.data);
          } else {
              console.log(333);
            Dialog.alert({
              message: "改页面已丢失"
            }).then(() => {
              // on close
              this.$router.push(
                "/home#/details？" + this.$route.fullPath.split("?")[1]
              );
            });
          }
        } else {
          Dialog.alert({
            message: "改页面已丢失"
          }).then(() => {
            // on close
            this.$router.push(
              "/home#/details？" + this.$route.fullPath.split("?")[1]
            );
          });
        }
      } catch (error) {
        Dialog.alert({
          message: "改页面已丢失"
        }).then(() => {
          // on close
          this.$router.push(
            "/home#/details？" + this.$route.fullPath.split("?")[1]
          );
        });
      }
    }
  },
  created() {
    console.log(this.$route.fullPath.split("?")[1]);
    this.getgood();
  }
};
</script>

<style scoped>
.icon {
  width: 0.2465rem;
  height: 0.2465rem;
  position: absolute;
  top: 0.0855rem;
  left: 0.0855rem;
}
img {
  width: 100%;
}
</style>